<template>
  <div class="report-form-content">
    <el-tabs type="border-card">
      <el-tab-pane label="合同变更">
        <div class="report-form-list-content">
          <div class="report-list">
            <label>合同名称：</label>
            <span>{{ obj.name }}</span>
          </div>
          <div class="report-list">
            <label>签订人：</label>
            <span>{{ showIdLabel(contractSignerList, obj.contractSignerId, 'name') }}</span>
          </div>
          <div class="report-list">
            <label>合同类型：</label>
            <span>{{ showIdLabel(contractTypeList, obj.type, 'name') }}</span>
          </div>
          <div class="report-list">
            <label>负责人：</label>
            <span>{{ showIdLabel(userList, obj.userId, 'name') }}</span>
          </div>
          <div class="report-list">
            <label>合同金额：</label>
            <span>{{ obj.amount }}</span>
          </div>
          <div class="report-list">
            <label>合同起始时间：</label>
            <span>{{ obj.contractLaunch }}</span>
          </div>
          <div class="report-list">
            <label>合同终止时间：</label>
            <span>{{ obj.contractComplete }}</span>
          </div>
          <div class="report-list">
            <label>合同终止时间：</label>
          </div>
          <div class="report-list">
            <span v-html="obj.content"></span>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="合同详情">
        <contractMainDetail :contractInitialId="obj.contractInitialId" />
      </el-tab-pane>
    </el-tabs> 
  </div>
</template>
<script setup>
import {ref, watch} from 'vue'
import {doGet} from "@/config/http";
import {svc, showIdLabel, getListPageSize} from "@/config/common";
import { useRoute, useRouter } from 'vue-router'
import contractMainDetail from '@/views/components/contract/contractMainDetail.vue'
import initListStore from '@/store/modules/initList'

const router = useRouter()
const route = useRoute()

const props = defineProps({
  contractChangeId: {
    required: true,
    type: String,
  }
})

let obj = ref({
    contractInitialId: route.query.id, // 合同ID
    createBy: '',	// 创建人用户ID
    createTime: '', // 创建时间
    name: '', // 合同名称
    contractSignerId: '', // 签订人
    departmentId: '', // 签订部门
    type: '', // 合同类型
    userId: '', // 负责人
    amount: '', // 合同金额
    contractLaunch: '', // 合同起始时间
    contractComplete: '', // 合同终止时间
    content: '', // 合同内容
    id: '', // 主键ID
  })

let contractTypeList = initListStore().contractTypeList // 合同类型
let userList = initListStore().userList // 用户
let contractSignerList = initListStore().contractSignerList // 签订人

// const initList = async () => {
//   contractSignerList,contractTypeList,userList
//   let p1 = doGet(svc, '/contract-type/page', {pageSize: getListPageSize()}, false) // 合同类型
//   let p2 = doGet(svc, '/contract-signer/page', {pageSize: getListPageSize()}, false) // 签订人
//   let p3 = doGet(svc, '/user/page', {pageSize: getListPageSize()}, false) // 用户

//   let resArray = await Promise.all([p1, p2, p3])
//   contractTypeList.value = resArray[0]['records']
//   contractSignerList.value = resArray[1]['records']
//   userList.value = resArray[2]['records']
// }

const initObj = async (val) =>  {
  if (val) {
    obj.value = await doGet(svc, `/contract-initial-change/${val}`, {}, true)
  }
}

watch(() => props.contractChangeId, async val => {
  await initObj(val)
  // await initList()
},{immediate:true})

</script>

<style scoped lang="scss">
.report-form-content {
  padding: 20px;
}
.tabs-list-head-2 {
  padding-left: 0 !important;
}
.tabs-list-head-2 span {
  font-size: 22px !important;
  color: #1ac4ad !important;
}
.tabs-list-head {
  padding-left: 20px;
  display: flex;
  align-items: center;
}
.tabs-list-head span {
  font-size: 18px;
  color: #303133;
  font-weight: bold;
}
.tabs-list-head-1 {
  margin-bottom: 30px;
}
.tabs-list-type {
  display: flex;
  align-items: center;
  justify-content: center;
}
.update-log {
  width: 100%;
  margin: 30px 0;
}
.update-log-1 {
  margin-top: 0;
}
.report-list {
  /* width: 100%; */
  width: 33%;
  margin: 15px;
  display: flex;
  align-items: center;
  /* justify-content: space-between; */
}
.report-list-a {

}
.report-list-a p {
  margin-left: 55px;
}
.report-list span:nth-child(1) {
  display: inline-block;
  width: 120px;
  text-align: right;
}
.steps {
  margin: 20px 0
}
</style>
